package com.bmf.module.rbac.controller;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bmf.module.rbac.entity.RbacPerms;
import com.bmf.module.rbac.service.RbacPermsService;
import com.bmf.module.rbac.vo.RbacPermsCreateVo;
import com.bmf.module.rbac.vo.RbacPermsResultVo;
import com.bmf.module.rbac.vo.RbacPermsUpdateVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;
import com.bmf.core.result.R;

/**
 * (RbacPerms)表控制层
 *
 * @author makejava
 * @since 2022-12-27 15:33:18
 */
@RestController
@RequestMapping("rbacPerms")
@Api(tags = {"权限接口"})
public class RbacPermsController{
    /**
     * 服务对象
     */
    @Autowired
    private RbacPermsService rbacPermsService;

    /**
     * 分页查询所有数据
     *
     * @return 所有数据
     */
    @GetMapping
    @ApiOperation(value = "查询所有权限")
    public R<List<RbacPermsResultVo>> selectAll() {
        return R.success(rbacPermsService.selectAll());
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation(value = "通过主键查询单条数据")
    public R<RbacPermsResultVo> selectOne(@PathVariable Serializable id) {
        return R.success(rbacPermsService.selectOne(id));
    }

    /**
     * 新增数据
     *
     * @param rbacPermsCreateVo 实体对象
     * @return 新增结果
     */
    @PostMapping
    @ApiOperation(value = "新增数据")
    public R<Integer> insert(@RequestBody RbacPermsCreateVo rbacPermsCreateVo) {
        return R.success(rbacPermsService.insert(rbacPermsCreateVo));
    }

    /**
     * 修改数据
     *
     * @param rbacPermsUpdateVo 实体对象
     * @return 修改结果
     */
    @PutMapping
    @ApiOperation(value = "修改数据")
    public R<Void> update(@RequestBody RbacPermsUpdateVo rbacPermsUpdateVo) {
        rbacPermsService.update(rbacPermsUpdateVo);
        return R.ok();
    }

    /**
     * 删除数据
     *
     * @param ids 主键结合
     * @return 删除结果
     */
    @DeleteMapping
    @ApiOperation(value = "删除数据")
    public R<Void> delete(@RequestBody List<Integer> ids) {
        rbacPermsService.delete(ids);
        return R.ok();
    }
}

